﻿namespace PhoneFilter
{
    using System;
    using System.IO;

    public class Log
    {
        public static void PrintLog(string log)
        {
            if (!log.EndsWith("\r\n"))
            {
                log = log + "\r\n";
            }
            string path = @"Log\";
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            try
            {
                using (FileStream stream = new FileStream(path + DateTime.Now.ToString("yyyyMMdd") + ".log", FileMode.Append))
                {
                    StreamWriter writer = new StreamWriter(stream);
                    writer.Write(log);
                    writer.Flush();
                    writer.Close();
                    stream.Close();
                }
            }
            catch
            {
            }
            Console.WriteLine(log);
        }
    }
}

